@import '../../style/github-button';

@header-height: 64px;
@menu-item-border: 2px;
@mobile-max-width: 767.99px;

#header {
  position: relative;
  z-index: 10;
  max-width: 100%;
  background: @component-background;
  box-shadow: 0 2px 8px rgba(240, 241, 242, 65);

  #logo strong {
    font-weight: 500;
  }

  .menu-row {
    display: flex;
    align-items: center;
    margin: 0;

    > * {
      flex: none;
      margin: 0 16px 0 0;

      &:last-child {
        margin-inline-end: 40px;
      }
    }
  }
}

@media only screen and (max-width: @mobile-max-width) {
  #header {
    text-align: center;
  }
}

#github-btn {
  display: flex;
  flex-flow: nowrap;
  height: auto;

  .gh-btn {
    height: auto;
    padding: 1px 4px;
    background: transparent;
    border: 0;

    .gh-ico {
      width: 20px;
      height: 20px;
      margin: 0;
    }

    .gh-text {
      display: none;
    }
  }

  .gh-count {
    min-width: 45px;
    height: auto;
    padding: 4px 8px;
    font-weight: normal;
    background: #fff;

    &:hover {
      color: @primary-color;
    }
  }

  &.responsive-mode {
    .gh-count {
      display: none !important;
    }
  }
}

#logo {
  height: @header-height;
  padding-inline-start: 40px;
  overflow: hidden;
  color: @site-heading-color;
  font-size: 18px;
  font-family: AlibabaSans, @font-family, sans-serif;
  line-height: @header-height;
  white-space: nowrap;
  text-decoration: none;

  img {
    position: relative;
    top: -1.5px;
    width: 28.27px;
    height: 32px;
    margin-inline-end: 16px;
  }
}

@media only screen and (max-width: @mobile-max-width) {
  #logo {
    padding-inline: 0;
  }
}

#nav {
  height: 100%;
  font-size: 14px;
  font-family: AlibabaSans, @font-family, sans-serif;
  border: 0;

  &.ant-menu-horizontal {
    border-bottom: none;

    & > .ant-menu-item,
    & > .ant-menu-submenu {
      min-width: (40px + 12px * 2);
      height: @header-height;
      padding-inline: 12px;
      line-height: @header-height;

      &::after {
        inset-inline: 12px;
        top: 0;
        bottom: auto;
        border-width: @menu-item-border;
      }
    }

    & .ant-menu-submenu-title .anticon {
      margin: 0;
    }

    & > .ant-menu-item-selected {
      a {
        color: @primary-color;
      }
    }
  }

  & > .ant-menu-item,
  & > .ant-menu-submenu {
    text-align: center;
  }
}

.header-link {
  color: @site-text-color;
}

.ant-menu-item-active .header-link {
  color: @primary-color;
}

// Popover menu is only used for mobile
.popover-menu {
  width: 300px;

  .ant-popover-inner-content {
    padding: 0;

    #nav {
      .ant-menu-item,
      .ant-menu-submenu {
        text-align: left;
      }

      .ant-menu-item-group-title {
        padding-inline-start: 24px;
      }

      .ant-menu-item-group-list {
        padding: 0 16px;
      }

      .ant-menu-item,
      a {
        color: #333;
      }
    }
  }
}

@search-icon-color: #ced4d9;

#search-box {
  position: relative;
  display: flex;
  flex: auto !important;
  align-items: center;
  height: 22px;
  margin-inline-end: auto;
  padding-inline-start: 16px;
  line-height: 22px;
  white-space: nowrap;
  border-inline-start: 1px solid @site-border-color-split;
  transition: width 0.5s;

  > * {
    flex: auto;
  }

  .anticon {
    position: absolute;
    top: 50%;
    z-index: 1;
    flex: none;
    color: @search-icon-color;
    transform: translateY(-50%);
    pointer-events: none;
  }

  input {
    width: 100%;
    max-width: 200px;
    padding-inline-start: 20px;
    font-size: 14px;
    background: transparent;
    border: 0;
    box-shadow: none;

    &::placeholder {
      color: #a3b1bf;
    }
  }

  // ================ Narrow ================
  &.narrow-mode {
    flex: none !important;
    width: 30px;

    &:hover {
      .anticon {
        color: #a3b1bf;
      }
    }

    .anticon {
      inset-inline-end: 0;
      inset-inline-start: auto;
    }

    input {
      max-width: none;
      padding-inline-start: 11px;
      padding-inline-end: 20px;
      cursor: pointer;
    }

    &.focused {
      width: 500px;

      .anticon {
        color: @search-icon-color;
      }

      input {
        cursor: text;
      }
    }
  }
}

#language {
  position: relative;
  width: 1.2em;
  height: 1.2em;
  transition: all 0.2s;

  span {
    position: absolute;
    color: rgba(0, 0, 0, 0.88);
    font-size: 1.2em;
    line-height: 1;
    border: 1px solid rgba(0, 0, 0, 0.88);
  }

  span.active {
    top: -5%;
    z-index: 1;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.88);
    transform: scale(0.7);
    transform-origin: 0 0;
    inset-inline-start: -5%;
  }

  span:not(.active) {
    inset-inline-end: -5%;
    bottom: -5%;
    z-index: 0;
    transform: scale(0.5);
    transform-origin: 100% 100%;
  }
}

#direction.rtl {
  svg {
    transform: scaleX(-1);
  }
}

.component-select {
  &.ant-select-dropdown {
    font-size: 14px;
    border: 0;
    border-radius: 0;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.25);
  }

  .ant-select-dropdown-menu {
    max-height: 200px;
  }

  .ant-select-dropdown-menu-item {
    border-radius: 0 !important;
  }
}

@media only screen and (max-width: @mobile-max-width) {
  #search-box {
    display: none;
  }
}
